import java.util.Scanner;

public class LinearEquatio {
    public static void main(String[]args){
        LinearEquatio t=init();
        System.out.println("X : "+t.getX());
        System.out.println("Y : "+t.getY());

    }
    public static LinearEquatio init(){
        System.out.println("equation:\naX+bY=e\ncX+dY=f\nplease input the value to calculate");
        Scanner scan=new Scanner(System.in);
        int a=getOneInt("a:",scan);
        int b=getOneInt("b:",scan);
        int e=getOneInt("e:",scan);
        int c=getOneInt("c:",scan);
        int d=getOneInt("d:",scan);
        int f=getOneInt("f:",scan);
        return new LinearEquatio(a,b,e,c,d,f);
    }
    private LinearTwoInt col1,col2,col3;
    public LinearEquatio(int a,int b,int e,int c,int d,int f){
        this.col1=new LinearTwoInt(a,c);
        this.col2=new LinearTwoInt(b,d);
        this.col3=new LinearTwoInt(e,f);
    }
    public static int getOneInt(Scanner in){
        return in.nextInt();
    }
    public static int getOneInt(String msg,Scanner in){
        System.out.print(msg);
        return getOneInt(in);
    }
    public double getX(){
        if(!isSolvable()){
            System.out.println("err");
            return Integer.MAX_VALUE;
        }else{
            return LinearTwoInt.det(col2,col3)/(double)LinearTwoInt.det(col1,col2)*-1;
        }
    }
    public double getY(){
        if(!isSolvable()){
            System.out.println("err");
            return Integer.MAX_VALUE;
        }else {
            return LinearTwoInt.det(col1,col3)/(double)LinearTwoInt.det(col1,col2);
        }
    }
    public boolean isSolvable(){
        return LinearTwoInt.NotCheck(col1,col2);
    }

}

class LinearTwoInt{
    public int f,b;
    public LinearTwoInt(int x,int y){
        this.f=x;
        this.b=y;
    }
    public void swap(){
        if(reverse()){
            int temp=f;
            this.f=this.b;
            this.b=temp;
        }
    }
    public boolean reverse(){
        return f<b;
    }
    public void set(int a,int b){
        this.f=a;
        this.b=b;
    }
    public static boolean NotCheck(LinearTwoInt col1,LinearTwoInt col2){
        return det(col1,col2)!=0;
    }
    public static int det(LinearTwoInt col1,LinearTwoInt col2){
        return col1.f*col2.b-col1.b*col2.f;
    }
}